<!--全部读者-->
<html>
<head>
    <meta charset="utf-8">
    <title>全部读者</title>
    <style>
        body {
            background-color: rgb(240, 242, 245);
        }
    </style>

</head>
<body>
<div class="panel panel-default" style="position:relative;width: 90%;margin-left: 5%">
    <div class="panel-heading">
        <h3 class="panel-title">
            全部读者
        </h3>
    </div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>读者号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>生日</th>
                <th>地址</th>
                <th>电话</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
            </thead>
            <tbody id="reader_all">
            <!--<c:forEach items="${readers}" var="reader">-->
            <!--            <tr>-->
            <!--                <td></td>-->
            <!--                <td></td>-->
            <!--                <td></td>-->
            <!--                <td></td>-->
            <!--                <td></td>-->
            <!--                <td></td>-->
            <!--                <td>-->
            <!--                    <a href="admin_reader_edit.html?readerId=">-->
            <!--                        <button type="button" class="btn btn-info btn-xs">编辑</button>-->
            <!--                    </a>-->
            <!--                </td>-->
            <!--                <td>-->
            <!--                    <a href="reader_delete.html?readerId=">-->
            <!--                        <button type="button" class="btn btn-danger btn-xs">删除</button>-->
            <!--                    </a>-->
            <!--                </td>-->
            <!--            </tr>-->
            <!--</c:forEach>-->
            </tbody>
        </table>
    </div>
</div>
<script>

    $(function () {
        $.ajax({
            type: "post",
            url: "user/allReaderMsg",
            dataType: "json",
            success: function (data) {
                var trs = '';
                $.each(data, function (index, ele) {

                    //alert(ele.reader_id);

                    trs += '<tr>\n' +
                        '                <td>'+ele.reader_id+'</td>\n' +
                        '                <td>'+ele.name+'</td>\n' +
                        '                <td>'+ele.sex+'</td>\n' +
                        '                <td>'+format(ele.birth)+'</td>\n' +
                        '                <td>'+ele.address+'</td>\n' +
                        '                <td>'+ele.telcode+'</td>\n' +
                        '                <td>\n' +
                        '                    <a class="jump2" name="admin_reader_edit.html?reader_id='+ele.reader_id+'">\n' +
                        '                        <button type="button" class="btn btn-info btn-xs">编辑</button>\n' +
                        '                    </a>\n' +
                        '                </td>\n' +
                        '                <td>\n' +
                        '                    <a class="jump2" name="user/del_reader?readerId='+ele.reader_id+'">\n' +
                        '                        <button type="button" class="btn btn-danger btn-xs">删除</button>\n' +
                        '                    </a>\n' +
                        '                </td>\n' +
                        '            </tr>'

                })
                $("#reader_all").html(trs);
                $(".jump2").click(function () {
                    setCookies($(this).prop("name"));
                    $("#middle").load($(this).prop("name"));
                });

                //alert(111);
            }
        })
    })


    function format(object) {
        var year = new Date(object).getFullYear(); //获取完整的年份(4位,1970-????)
        var month = new Date(object).getMonth() + 1; //获取当前月份(0-11,0代表1月)
        var day = new Date(object).getDate(); //获取当前日(1-31)
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var dateString =  year + "-" + month + "-" + day;
        return dateString;

    }

</script>
</body>
<script src="js/integrationJS.js"></script>
</html>
